import requests

u = 'http://wthrcdn.etouch.cn/weather_mini?city='
while True:
    try:
        city = input('请输入要查询的城市名称，回车退出：')
        if not city :
            break
        url = u +city
        req = requests.get(url)
        date_dic = req.json()
        n = (date_dic.get('data')).get('forecast')
        n = n[0]
        data = '%s\n%s\n%s\n%s\n%s'%(city,n['date'],n['high'],n['low'],n['type'])
        print(data)
    except  AttributeError:
        print('%s\n未获得数据'%city)